package com.es.spring_es.rabbitmq.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Definition {

    @Bean("exchange")
    public TopicExchange exchange() {
        return new TopicExchange("exchange", true, false);
    }

    @Bean("track")
    public Queue completeOrder() {
        return new Queue("track");
    }

    @Bean
    Binding bindingExchangeMessage(@Qualifier("track") Queue queueMessage, @Qualifier("exchange") TopicExchange exchange) {
        return BindingBuilder.bind(queueMessage).to(exchange).with("track");
    }

}
